<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/views/common/taglibs.jsp" %>

<!DOCTYPE>
<html>
<head>
    <!-- 引入通用js、css文件(xiaogq) -->
    <meta name="decorator" content="bootstrap"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common/operation/sys_operation.css"/>
</head>
<body>
    <!-- 加载列表操作 -->
    <div class="button_list">
        <a href="javascript:;" onclick="addSelectBoxEnum(this);">
            <span class="span_button">
                <span><img src="${ctx}/image/common/operation/oper_ADD.png"></span>
                <span name="buTitle">新建</span>
            </span>
        </a>
        <a href="javascript:;" onclick="sortSelectBoxEnum(this);">
            <span class="span_button">
                <span><img src="${ctx}/image/common/operation/oper_sort.png"></span>
                <span name="buTitle">排序</span>
            </span>
        </a>
        <a href="javascript:;" onclick="javascript:parent.closeTab();">
            <span class="span_button">
                <span><img src="${ctx}/image/common/operation/oper_CANCEL.png"></span>
                <span name="buTitle">取消</span>
            </span>
        </a>
    </div>

    <div class="selectbox_div">
        <table id="selectbox_table"
               data-striped="true"
               data-toggle="table"
               data-show-columns="false"
               data-cookie="false"
               data-pagination="false"
               data-search="false"
               data-url="${ctx}/FieldRecord/queryFieldSelectBoxList.do?fieldId=${fieldId}"
               data-side-pagination="server"
               data-checkbox-header="true"
               data-page-list="[10,20,30,1000]"
               class="table">
            <thead>
            <tr>
                ${columns}
            </tr>
            </thead>
        </table>
    </div>

    <script type="text/javascript">
        //添加枚举值方法(xiaogq)
        function addSelectBoxEnum(node) {
            var url = Constants.selectBoxAddInitUrl+"?entityId=${entityId}&fieldId=${fieldId}";
            //打开tabls标签
            //parent.addMenu(node,{title:"新建枚举值",url:url,type:"R"});
            var node = {id: "addSelectBoxEnum${entityId}", text:"新建枚举值", url:url};
            parent.showTab(node);
        }

        //编辑枚举值方法
        function editSelectBoxEnum(node) {
            //获取枚举值id
            var id = $(node).attr("id");
            var title = $(node).attr("title");
            var name = $(node).attr("name");
            var url = $(node).attr("url")+"?selectBoxId="+id;
            //打开tabls标签
            //parent.addMenu(node,{title:title+":"+name,url:url,type:"R"});
            var node = {id: "editSelectBoxEnum${entityId}", text:title+":"+name, url:url};
            parent.showTab(node);
        }

        //删除枚举值方法(xiaogq)
        function delSelectBoxEnum(node) {
            //获取枚举值id
            var id = $(node).attr("id");
            var url = $(node).attr("url")+"?selectBoxId="+id;
            if(confirm(" 确定要删除本字段枚举值吗?")){
                $.ajax({
                    url : "${ctx}/"+url,
                    type :'GET',
                    success : function(data){
                        var ifvlid = data.suc;
                        if (ifvlid == "success"){
                            $("#selectbox_table").bootstrapTable("refresh");
                        }else if(ifvlid == "sys"){
                            alert("系统枚举值不能删除!");
                        }else{
                            alert("该状态已被引用不能删除!");
                        }

                    },
                    error : function(){
                        alert("枚举值被使用");
                    }
                });
            }
        }

        //枚举值排序方法(xiaogq)
        function sortSelectBoxEnum(node) {
            var fieldId = "${fieldId}";
            var url = Constants.selectBoxSortUrl+"?fieldId="+fieldId;
            //打开tabls标签
            //parent.addMenu(node,{title:"字段排序",url:url,type:"R"});
            var node = {id: "sortSelectBoxEnum"+fieldId, text:"字段排序", url:url};
            parent.showTab(node);
        }

        //关闭模态框方法(xiaogq)
        function closeModal(){
            $('#selectBoxModal').modal('hide');
        }
    </script>
    <!-- 引入出来表格列头操作按钮方法js(xiaogq) -->
    <script type="text/javascript" src="${ctx}/js/system/operation/show_colOperation.js"></script>
</body>
</html>
